ReorderLevelNotification.prepare   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 29
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 29
c 0
b 0
f 0
rs 9.75
cc 1
1
import { BaseMailer, MessageContract } from '@ioc:Adonis/Addons/Mail'
2
import Env from '@ioc:Adonis/Core/Env'
3
import I18n from '@ioc:Adonis/Addons/I18n'
4
import Merchant from 'App/Models/Merchant'
5
import Ingredient from 'App/Models/Ingredient'
6
7
export default class ReorderLevelNotification extends BaseMailer {
8
  constructor (private merchant: Merchant, private ingredient: Ingredient) {
9
    super()
10
  }
11
12
  /**
13
   * WANT TO USE A DIFFERENT MAILER?
14
   *
15
   * Uncomment the following line of code to use a different
16
   * mailer and chain the ".options" method to pass custom
17
   * options to the send method
18
   */
19
  // public mailer = this.mail.use()
20
21
  /**
22
   * The prepare method is invoked automatically when you run
23
   * "ReorderLevelNotification.send".
24
   *
25
   * Use this method to prepare the email message. The method can
26
   * also be async.
27
   */
28
  public prepare(message: MessageContract) {
29
    message
30
      .subject(I18n.locale('en').formatMessage('order.mail.subject'))
31
      .from(Env.get('SMTP_USERNAME'))
32
      .to(this.merchant.email)
33
      .htmlView('emails/welcome', {
34
        user: this.merchant,
35
        introduction: I18n.locale('en').formatMessage('order.mail.introduction', {name: this.merchant.name}),
36
        message: I18n.locale('en').formatMessage('order.mail.message', {name: this.ingredient.name}),
37
        action: I18n.locale('en').formatMessage('order.mail.action'),
38
        complimentaryClose: I18n.locale('en').formatMessage('order.mail.complimentary_close'),
39
        url: Env.get('APP_URL'),
40
      })
41
  }
42
}
43